LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
USE IEEE.STD_LOGIC_UNSIGNED.ALL;

ENTITY led_select IS
PORT(
	sech,secl:IN STD_LOGIC_VECTOR(3 DOWNTO 0);
	clk_select:IN STD_LOGIC;
	q:OUT STD_LOGIC_VECTOR(7 DOWNTO 0);--select which led segment will be lighten 
	dataout:OUT STD_LOGIC_VECTOR(3 DOWNTO 0)--select what number led will show
);
END;

ARCHITECTURE behave OF led_select IS
	SIGNAL highorlow:STD_LOGIC;-- according to clk to judge which led segement will be lighten
BEGIN 
	p1:PROCESS(clk_select)
		BEGIN
		IF(clk_select'EVENT AND clk_select='1')THEN
			highorlow<=NOT highorlow;
		END IF;
	END PROCESS p1;
	
	p2:	PROCESS(highorlow,secl,sech)
		BEGIN 
			CASE highorlow IS
				WHEN '0'=>dataout<=secl;q<="11111110";--low bit
				WHEN '1'=>dataout<=sech;q<="11111101";--high bit
				WHEN OTHERS=>NULL;
			END CASE;
	END PROCESS p2;
END behave;